package com.manage.controller;

import com.beans.Customer;
import com.beans.page.PageList;
import com.manage.util.UserUtils;
import com.services.CustomerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author jiangwei
 * @since 18/1/22
 */
@Controller
@RequestMapping("invalidCustomer")
public class CustomerInvalidController extends BaseController{

    @Autowired
    private CustomerService customerService;

    /**
     * 查询列表
     *
     * @param customer
     * @return
     */
    @RequiresPermissions("customer:view")
    @RequestMapping(value = {"", "/", "list"})
    public String list(Customer customer, Long relationId, HttpServletRequest request) {

        customer.setCreateBy(UserUtils.getUser().getUserId());
        request.setAttribute("customer", customer);
        return "customer/nothing";
    }

    /**
     * 异步获取list资源
     *
     * @param pageList
     * @param customer
     * @return
     */
    @RequiresPermissions("customer:view")
    @RequestMapping("asynList")
    @ResponseBody
    public PageList asynList(PageList pageList, Customer customer) {
        customer.setCreateBy(UserUtils.getUser().getUserId());
        return customerService.queryPageNothingByCustomer(pageList, customer);
    }
}
